﻿using System.Collections.Generic;
using AbstractBugTracker;
using SmartAssembly;
using Utilities;

namespace Engine.Buggets
{
    internal sealed class Commenter<TBug, TBugDef> : IBugget<TBug>
        where TBug : class, IBug
        where TBugDef : BugDef
    {
        private readonly IBugPresenter<TBug, TBugDef> m_BugPresenter;

        internal Commenter(IBugPresenter<TBug, TBugDef> bugPresenter)
        {
            m_BugPresenter = bugPresenter;
        }

        public IEnumerable<Tuple<ProcessedReport, TBug>> Run(ProcessedReport processedReport, TBug bug)
        {
            string body = m_BugPresenter.GetReportCommentFor(bug, processedReport);
            bug.AddComment(body, true);

            yield return new Tuple<ProcessedReport, TBug>(processedReport, bug);
        }
    }
}
